[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 tell()                  Get Current File Pointer Position

 #include   <io.h>                       Required for declarations only

 long       tell(handle);
 int        handle;                      Handle referring to open file

    tell() gets the current position of the file pointer associated with
    'handle'.  The position is returned as the number of bytes from the
    beginning of the file.

       Returns:     The current file-pointer position, if successful; -1L
                    if an error occurs. On error, 'errno' is set to EBADF
                    (invalid file handle)

         Notes:     tell() does not reposition the pointer.

   -------------------------------- Example ---------------------------------

    The following statements open a file, get the current position, move
    to a different position, then restore the pointer to the saved
    position.

           #include <io.h>
           #include <stdio.h>
           #include <fcntl.h>

           int fhndl;
           long position;

           main()
           {
               fhndl = open("c:\comp\invoice.dat",O_RDWR);
               .
               .
               position = tell(fhndl);
               lseek(fhndl,0L,SEEK_SET);
               .
               .
               lseek(fhndl,position,0);
           }


See Also: ftell() lseek()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson